package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.CourseTeacherDto;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "课程教师信息管理接口")
public class CourseTeacherController {

    @Autowired
    private CourseTeacherService courseTeacherService;

    /**
     * 根据课程id查询教师信息
     * @param courseId
     * @return
     */
    @ApiOperation("根据课程id查询教师信息")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacherDto> list(@PathVariable Long courseId){
        return courseTeacherService.list(courseId);
    }

    /**
     * 新增教师师信息
     */
    @ApiOperation("新增教师信息")
    @PostMapping("/courseTeacher")
    public CourseTeacherDto save(@RequestBody CourseTeacherDto courseTeacherDto){
        return courseTeacherService.add(courseTeacherDto);
    }

    /**
     * 新增教师信息
     */
    @ApiOperation("修改教师信息")
    @PutMapping("/courseTeacher")
    public CourseTeacherDto update(@RequestBody CourseTeacherDto courseTeacherDto){
        log.info("修改教师信息:{}",courseTeacherDto);

        return courseTeacherService.updateInfo(courseTeacherDto);
    }

    /**
     * 删除教师信息
     */
    @ApiOperation("删除教师信息")
    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    public void delete(@PathVariable Long courseId,@PathVariable Long id){
        log.info("删除教师信息:{}",id);
        courseTeacherService.delete(courseId,id);
    }

}
